﻿Public Class ThaoTacPLThuChi
    Public index As Integer
    Public Sub AddTitle(ByVal txt As String)
        ThayDoi_PLThuChi2.Label_action.Text = txt
    End Sub
    Public Sub CleanTextBox()
        ThayDoi_PLThuChi2.tb_ten.Text = ""
    End Sub
    Public Sub AddUsername(ByVal name As String, ByVal id_usr As Integer)
        ThayDoi_PLThuChi2.Flag = 0
        ThayDoi_PLThuChi2.tb_user.Text = name
        ThayDoi_PLThuChi2.id_user = id_usr
    End Sub
    Public Sub EditItem(ByVal pltc As PLThuChi)
        ThayDoi_PLThuChi2.DSTemp = PhanLoaiThuChi.DSPLThuChi
        ThayDoi_PLThuChi2.Flag = 1
        ThayDoi_PLThuChi2.id = pltc.id
        ThayDoi_PLThuChi2.tb_ten.Text = pltc.ten
        ThayDoi_PLThuChi2.tb_user.Text = pltc.username
        ThayDoi_PLThuChi2.id_user = pltc.id_user
    End Sub

    Private Sub ThayDoi_PLThuChi2_SuKienClickButtonDong() Handles ThayDoi_PLThuChi2.SuKienClickButtonDong
        Me.Close()
    End Sub

    Private Sub ThayDoi_PLThuChi2_SuKienClickButtonLuu(plThuChi As QuanLyThuChi.PLThuChi, loai As System.Int32) Handles ThayDoi_PLThuChi2.SuKienClickButtonLuu
        If Not plThuChi Is Nothing And loai = 0 Then
            Dim dongmoi As DataRow = PhanLoaiThuChi.DSPLThuChi.NewRow
            dongmoi(0) = plThuChi.id
            dongmoi(1) = plThuChi.ten
            dongmoi(2) = plThuChi.username
            dongmoi(3) = plThuChi.id_user
            PhanLoaiThuChi.DSPLThuChi.Rows.Add(dongmoi)
        ElseIf Not plThuChi Is Nothing And loai = 1 Then
            PhanLoaiThuChi.DSPLThuChi.Rows(index).Item(0) = plThuChi.id
            PhanLoaiThuChi.DSPLThuChi.Rows(index).Item(1) = plThuChi.ten
            PhanLoaiThuChi.DSPLThuChi.Rows(index).Item(2) = plThuChi.username
            PhanLoaiThuChi.DSPLThuChi.Rows(index).Item(3) = plThuChi.id_user
        End If
    End Sub
End Class